import { Component, OnInit , Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {AuthService} from "../../../auth/auth.service";

@Component({
  selector: 'app-user-center',
  templateUrl: './user-center.component.html',
  styleUrls: ['./user-center.component.less']
})
export class UserCenterComponent implements OnInit {
  @Input() topbar;
  user;
  constructor(private authService: AuthService) { }

  ngOnInit() {
    const login = localStorage.getItem('login');
    if (login) {
      this.user = JSON.parse(login);
    } else {
      this.user = null;
    }
  }
  onSignOut() {
    this.authService.logout();
      localStorage.removeItem('login');
      this.user = null;
  }
}
